var _handleActions, _handleActions2, _handleActions3;

import { combineReducers } from 'redux';
import handleActions from '../libs/handleActions';

// ------------------------------------
// Constants
// ------------------------------------

export var ERROR_MODAL_SHOW = 'ERROR_MODAL_SHOW';
export var ERROR_MODAL_HIDE = 'ERROR_MODAL_HIDE';

export var ERROR_ALERT_SHOW = 'ERROR_ALERT_SHOW';
export var ERROR_ALERT_HIDE = 'ERROR_ALERT_HIDE';

export var MODAL_SHOW = 'MODAL_SHOW';
export var MODAL_HIDE = 'MODAL_HIDE';

// ------------------------------------
// Actions
// ------------------------------------

// show/hide error modal
export var errorModal = function errorModal(payload) {
  return {
    type: ERROR_MODAL_SHOW,
    payload: payload
  };
};

export var errorModalHide = function errorModalHide() {
  return {
    type: ERROR_MODAL_HIDE
  };
};

// show/hide error errorAlert
export var errorAlert = function errorAlert(payload) {
  return {
    type: ERROR_ALERT_SHOW,
    payload: payload
  };
};

export var errorAlertHide = function errorAlertHide() {
  return {
    type: ERROR_ALERT_HIDE
  };
};

// show/hide modal
export var modal = function modal(view, data) {
  return {
    type: MODAL_SHOW,
    payload: { view: view, data: data }
  };
};

export var modalHide = function modalHide() {
  return {
    type: MODAL_HIDE
  };
};

// ------------------------------------
// Reducers
// ------------------------------------

var errorModalReducer = handleActions((_handleActions = {}, _handleActions[ERROR_MODAL_SHOW] = function (state, _ref) {
  var payload = _ref.payload;
  return payload;
}, _handleActions[ERROR_MODAL_HIDE] = function () {
  return false;
}, _handleActions), false);

var errorAlertReducer = handleActions((_handleActions2 = {}, _handleActions2[ERROR_ALERT_SHOW] = function (state, _ref2) {
  var payload = _ref2.payload;
  return payload;
}, _handleActions2[ERROR_ALERT_HIDE] = function () {
  return false;
}, _handleActions2), false);

var modalReducer = handleActions((_handleActions3 = {}, _handleActions3[MODAL_SHOW] = function (state, _ref3) {
  var payload = _ref3.payload;
  return payload;
}, _handleActions3[MODAL_HIDE] = function () {
  return false;
}, _handleActions3), false);

export default combineReducers({
  errorModal: errorModalReducer,
  errorAlert: errorAlertReducer,
  modal: modalReducer
});